package com.xinzhi.controller;

import com.xinzhi.pojo.User;
import com.xinzhi.service.ISetPasswordService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SetPasswordController {
    @Autowired
    private ISetPasswordService setPasswordService;

    /**
     * 设置密码
     * @param phone
     * @param password
     * @param quePassword
     * @return
     */
    @PostMapping("/setPassword")
    public Result setPassword(String phone, String password,String quePassword){
        return setPasswordService.setPassword(phone, password,quePassword);
    }
    /**
     * 修改用户密码
     *
     * @param phone 用户手机号
     * @param oldPassword旧密码
     * @param newPassword新密码
     * @param quePassword 确认密码
     * @return 返回操作结果
     */

    @PostMapping("/updatePassword")
    public Result updatePassword(String phone, String oldPassword, String newPassword,String qrPassword){
        return setPasswordService.updatePassword(phone, oldPassword, newPassword,qrPassword);
    }
/**
 * 根据手机号查询用户
 *
 * @param phone 用户手机号
 *
 * @return 返回用户信息
 */
    @PostMapping("/getUserByPhone")
    public User getUserByPhone(String phone){
        return setPasswordService.getUserByPhone(phone);
    }
}
